/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1626666131922_3438';

  // add your middleware config here
  config.middleware = [];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };
  config.view = {
    defaultViewEngine: 'nunjucks',
  };

  // 配置允许post请求
  config.security = {
    csrf: {
      enable: false,
    },
  };

  // 配置跨域
  config.cors = {
    origin: '*',
    allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH',
  };


  config.sequelize = {
    dialect: 'mysql', // 数据库环境
    host: 'sh-cdb-o362wl2i.sql.tencentcdb.com',
    port: 60980,
    // host: '172.17.0.16',
    // port: 3306,
    database: 'test_coding', // 数据库名称
    username: 'root', // 账号
    password: 'fLNkg5IE5xrvb4qE', // 密码
    define: {
      // 字段以下划线（_）来分割（默认是驼峰命名风格）
      underscored: true,
      underscoredAll: true,
      // 是否冻结表名Cannot add or update a child row: a foreign key constraint fails
      freezeTableName: true,
    },
    timezone: '+08:00',
    // 控制updated_at created_at 设置为false就没有这两个字段
    timestamps: true,
    // 删除数据时会添加多一个删除时的字段
    paranoid: true,
  };
  // 配置jwt
  // config.jwt = { secret: "xiaozhoubaogao" }
  return {
    ...config,
    ...userConfig,
  };

};
